package main

import "fmt"

var writeData chan int
var readDate chan bool

func write(write chan int) {
	for i := 0; i < 50; i++ {
		write <- i
		fmt.Println("写入", i)
	}
	close(write)
}

func read(write chan int, read chan bool) {
	for {
		_, ok := <-write
		if !ok {
			break
		}
	}
	read <- true
	close(read)
}
func main() {
	writeData = make(chan int, 50)
	readDate = make(chan bool)
	go write(writeData)
	go read(writeData, readDate)
	for {
		ok := <-readDate
		if ok {
			break
		}

	}

}
